﻿using WikiMaml.Renderers;
using Xunit;
using Xunit.Extensions;

namespace WikiMaml.Facts.Renderers
{
    public class TopicRendererFacts
    {
        public class CanExpand
        {
            [Theory]
            [InlineData(MamlScopeName.ConceptualTopicBegin)]
            [InlineData(MamlScopeName.ConceptualTopicEnd)]
            [InlineData(MamlScopeName.WalkthroughTopicBegin)]
            [InlineData(MamlScopeName.WalkthroughTopicEnd)]
            public void Should_be_able_to_expand_scope_name(string scopeName)
            {
                var renderer = new TopicRenderer();

                bool result = renderer.CanExpand(scopeName);

                Assert.True(result);
            }
        }

        public class Expand
        {
            [Theory]
            [InlineData(MamlScopeName.ConceptualTopicBegin, "developerConceptualDocument")]
            [InlineData(MamlScopeName.WalkthroughTopicBegin, "developerWalkthroughDocument")]
            public void Should_expand_the_topic_begin_correctly(string scopeName, string tagName)
            {
                var renderer = new TopicRenderer();

                string actualResult = renderer.Expand(scopeName, "asdf-asdf", x => x, x => x);

                Assert.Equal(string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?><topic id=""asdf-asdf"" revisionNumber=""1""><{0} xmlns=""http://ddue.schemas.microsoft.com/authoring/2003/5"" xmlns:xlink=""http://www.w3.org/1999/xlink"">", tagName), actualResult);
            }

            [Theory]
            [InlineData(MamlScopeName.ConceptualTopicEnd, "developerConceptualDocument")]
            [InlineData(MamlScopeName.WalkthroughTopicEnd, "developerWalkthroughDocument")]
            public void Should_expand_the_conceptual_topic_closing_correctly(string scopeName, string tagName)
            {
                var renderer = new TopicRenderer();

                string actualResult = renderer.Expand(scopeName, string.Empty, x => x, x => x);

                Assert.Equal(string.Format("</{0}></topic>", tagName), actualResult);
            }
        }
    }
}
